# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from datetime import datetime

from django.db import models
from django.contrib.auth.models import AbstractUser


# Create your models here.

# class UserMessage(models.Model):
#     object_id = models.CharField(max_length=50,default='',primary_key=True,verbose_name=u'主键')
#     name = models.CharField(max_length=20,verbose_name=u'用户名')
#     email = models.EmailField(verbose_name=u'邮箱')
#     address = models.CharField(max_length=100,verbose_name=u'联系地址')
#     message = models.CharField(max_length=500,verbose_name=u'留言信息')
#
#     class Meta:
#         verbose_name = u'用户留言信息'
#         verbose_name_plural = verbose_name
#         # db_table = 'table_name'
#         # ordering = '- object_id'


class Category(models.Model):
    name = models.CharField(max_length=20, verbose_name=u'课程')
    summary = models.CharField(max_length=50, verbose_name=u'摘要')
    status = models.BooleanField(verbose_name=u'状态')
    remark = models.CharField(max_length=50, verbose_name=u'评论')
    create_user = models.ForeignKey(AbstractUser,verbose_name=u'创建者')
    create_time = models.DateTimeField(default=datetime.now, verbose_name=u'创建时间')
    update_user = models.ForeignKey(AbstractUser, verbose_name=u'修改者')
    update_time = models.DateTimeField(default=datetime.now, verbose_name=u'修改时间')

    class Meta:
        verbose_name = u'课程'
        verbose_name_plural = verbose_name


class Section(models.Model):
    name = models.CharField(max_length=20, verbose_name=u'章节名')
    summary = models.CharField(max_length=50, verbose_name=u'摘要')
    category_id = models.ForeignKey(Category, verbose_name=u'课程')
    status = models.BooleanField(verbose_name=u'状态')
    remark = models.CharField(max_length=50, verbose_name=u'评论')
    create_user = models.ForeignKey(AbstractUser, verbose_name=u'创建者')
    create_time = models.DateTimeField(default=datetime.now, verbose_name=u'创建时间')
    update_user = models.ForeignKey(AbstractUser, verbose_name=u'修改者')
    update_time = models.DateTimeField(default=datetime.now, verbose_name=u'修改时间')

    class Meta:
        verbose_name = u'章节'
        verbose_name_plural = verbose_name


class Video(models.Model):
    name = models.CharField(max_length=20, verbose_name=u'视频名')
    summary = models.CharField(max_length=50, verbose_name=u'摘要')
    section_id = models.ForeignKey(Section, verbose_name=u'章节')
    teacher_id = models.ForeignKey(AbstractUser, verbose_name=u'讲师')
    video_length = models.IntegerField(max_length=11, verbose_name=u'视频长度')
    url = models.URLField(max_length=100, verbose_name=u'视频链接')
    hit = models.IntegerField(max_length=11, verbose_name=u'点击量')
    cover = models.ImageField(max_length=100, verbose_name=u'封面图')
    status = models.BooleanField(verbose_name=u'状态')
    remark = models.CharField(max_length=50, verbose_name=u'评论')
    create_user = models.ForeignKey(AbstractUser, verbose_name=u'创建者')
    create_time = models.DateTimeField(default=datetime.now, verbose_name=u'创建时间')
    update_user = models.ForeignKey(AbstractUser, verbose_name=u'修改者')
    update_time = models.DateTimeField(default=datetime.now, verbose_name=u'修改时间')

    class Meta:
        verbose_name = u'视频'
        verbose_name_plural = verbose_name